---
title: "Create Agent"
api: "POST labs.chonkie.ai/api/v1/agents"
description: "Create an AI agent with custom configuration and knowledge base access"
---

Create a new AI agent with customizable LLM settings, system prompts, and knowledge base integration.

## Examples

<CodeGroup>

```python Python
import requests

url = "https://labs.chonkie.ai/api/v1/agents"
headers = {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json"
}

data = {
    "name": "Documentation Assistant",
    "description": "Helps users navigate product documentation",
    "model": "gpt-4o-mini",
    "systemPrompt": "You are a helpful documentation assistant. Answer questions clearly and concisely.",
    "temperature": 0.3,
    "maxContextChunks": 5,
    "useContext": True,
    "knowledge": "product-documentation"
}

response = requests.post(url, headers=headers, json=data)
result = response.json()

print(f"Created agent: {result['agent']['name']}")
print(f"Slug: {result['slug']}")
```

```javascript JavaScript
const response = await fetch("https://labs.chonkie.ai/api/v1/agents", {
  method: "POST",
  headers: {
    Authorization: "Bearer YOUR_API_KEY",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    name: "Documentation Assistant",
    description: "Helps users navigate product documentation",
    model: "gpt-4o-mini",
    systemPrompt: "You are a helpful documentation assistant.",
    temperature: 0.3,
    maxContextChunks: 5,
    useContext: true,
    knowledge: "product-documentation",
  }),
});

const result = await response.json();
console.log(`Created agent: ${result.agent.name}`);
console.log(`Slug: ${result.slug}`);
```

```bash cURL
curl -X POST https://labs.chonkie.ai/api/v1/agents \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Documentation Assistant",
    "description": "Helps users navigate product documentation",
    "model": "gpt-4o-mini",
    "systemPrompt": "You are a helpful documentation assistant.",
    "temperature": 0.3,
    "maxContextChunks": 5,
    "useContext": true,
    "knowledge": "product-documentation"
  }'
```

</CodeGroup>

## Request

#### Parameters

<ParamField path="name" type="string" required>
  Agent name (3-100 characters).
</ParamField>

<ParamField path="description" type="string">
  Description of the agent's purpose and capabilities.
</ParamField>

<ParamField path="model" type="string" default="gpt-5-mini">
  LLM model to use. We support OpenAI models.
</ParamField>

<ParamField path="systemPrompt" type="string">
  System prompt that defines the agent's behavior and personality.
</ParamField>

<ParamField path="maxContextChunks" type="integer" default="5">
  Maximum number of knowledge base chunks to include in context.
</ParamField>

<ParamField path="useContext" type="boolean" default="false">
  Whether to inject knowledge base context into conversations.
</ParamField>

<ParamField path="knowledge" type="string">
  Knowledge base slug to use for context (required if useContext is true).
</ParamField>

## Response

#### Returns

<ResponseField name="slug" type="string">
  Unique slug for the agent (used in API calls).
</ResponseField>

<ResponseField name="agent" type="object">
  Complete agent configuration object.
</ResponseField>

**Each agent object contains the following fields**

**Basic Information**

<ParamField path="id" type="string">
  Unique agent identifier.
</ParamField>

<ParamField path="slug" type="string">
  URL-friendly unique identifier for the agent.
</ParamField>

<ParamField path="name" type="string">
  Display name of the agent.
</ParamField>

<ParamField path="description" type="string">
  Description of the agent's purpose and capabilities.
</ParamField>

<ParamField path="status" type="string">
  Agent status (active, inactive, etc.).
</ParamField>

**Model Configuration**

<ParamField path="model" type="string">
  The LLM model used by the agent.
</ParamField>

<ParamField path="systemPrompt" type="string">
  System prompt that defines the agent's behavior and personality.
</ParamField>

<ParamField path="temperature" type="float">
  Temperature setting for response randomness (0.0-2.0).
</ParamField>

**Knowledge Integration**

<ParamField path="useContext" type="boolean">
  Whether knowledge base context injection is enabled.
</ParamField>

<ParamField path="knowledge" type="string">
  Slug of the connected knowledge base (if any).
</ParamField>

<ParamField path="maxContextChunks" type="integer">
  Maximum number of knowledge base chunks to include in context.
</ParamField>

**Metadata**

<ParamField path="organizationSlug" type="string">
  Organization that owns this agent.
</ParamField>

<ParamField path="metadata" type="object">
  Additional custom metadata.
</ParamField>

<ParamField path="createdAt" type="string">
  Timestamp when the agent was created.
</ParamField>

<ParamField path="updatedAt" type="string">
  Timestamp when the agent was last updated.
</ParamField>
